#!/bin/bash
set -e

if [ -z $1 ]
then
    echo "Usage : ./new_project [name]"
    exit 1
fi

if [ ! -d $1 ]
then
    mkdir $1
else
    echo "Project $1 already exists, overwrite it ? [y/n]"
    read answer
    if [ $answer = "y" ]
    then
        rm -rf $1
        mkdir $1
    else
        echo "Exit."
        exit 1
    fi
fi
chmod u+rwx $1
mkdir $1/data

now=`dirname $0`
cp $now/config.ini $1/config.ini
cp $now/autoplot.py $1/autoplot.py
cp $now/frameviewer.py $1/frameviewer.py
# cp $now/mask_sample.byt $1/data/mask_sample.byt

echo " "
echo "Successfully created work directory : $1"
